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KKwkJCQlkb2l0ID0gMTsKKwkJCSAgICB9CisJCQl9CisJCQlpZiAoZG9pdCkgeworCQkJICAgIGlmIChkaXJjID09ICcgJykgeworCQkJCXByaW50ZiAoIiAlOGxkICAgJXMlY1xuIiwKKwkJCQkJKGxvbmcpIEZBVDJDUFUzMiAoZGVudHB0ci0+c2l6ZSksCisJCQkJCWxfbmFtZSwgZGlyYyk7CisJCQkgICAgfSBlbHNlIHsKKwkJCQlwcmludGYgKCIgICAgICAgICAgICAlcyVjXG4iLCBsX25hbWUsIGRpcmMpOworCQkJICAgIH0KKwkJCX0KKwkJCWRlbnRwdHIrKzsKKwkJCWNvbnRpbnVlOworCQkgICAgfQorCQkgICAgRkFUX0RQUklOVCAoInZmYXRuYW1lOiB8JXN8XG4iLCBsX25hbWUpOworCQl9IGVsc2UKKyNlbmRpZgorCQl7CisJCSAgICAvKiBWb2x1bWUgbGFiZWwgb3IgVkZBVCBlbnRyeSAqLworCQkgICAgZGVudHB0cisrOworCQkgICAgY29udGludWU7CisJCX0KKwkgICAgfQorCSAgICBpZiAoZGVudHB0ci0+bmFtZVswXSA9PSAwKSB7CisJCWlmIChkb2xzKSB7CisJCSAgICBwcmludGYgKCJcbiVkIGZpbGUocyksICVkIGRpcihzKVxuXG4iLCBmaWxlcywgZGlycyk7CisJCX0KKwkJRkFUX0RQUklOVCAoIkRlbnRuYW1lID09IE5VTEwgLSAlZFxuIiwgaSk7CisJCXJldHVybiBOVUxMOworCSAgICB9CisjaWZkZWYgQ09ORklHX1NVUFBPUlRfVkZBVAorCSAgICBpZiAoZG9scyAmJiBta2Nrc3VtIChkZW50cHRyLT5uYW1lKSA9PSBwcmV2Y2tzdW0pIHsKKwkJZGVudHB0cisrOworCQljb250aW51ZTsKKwkgICAgfQorI2VuZGlmCisJICAgIGdldF9uYW1lIChkZW50cHRyLCBzX25hbWUpOworCSAgICBpZiAoZG9scykgeworCQlpbnQgaXNkaXIgPSAoZGVudHB0ci0+YXR0ciAmIEFUVFJfRElSKTsKKwkJY2hhciBkaXJjOworCQlpbnQgZG9pdCA9IDA7CisKKwkJaWYgKGlzZGlyKSB7CisJCSAgICBkaXJzKys7CisJCSAgICBkaXJjID0gJy8nOworCQkgICAgZG9pdCA9IDE7CisJCX0gZWxzZSB7CisJCSAgICBkaXJjID0gJyAnOworCQkgICAgaWYgKHNfbmFtZVswXSAhPSAwKSB7CisJCQlmaWxlcysrOworCQkJZG9pdCA9IDE7CisJCSAgICB9CisJCX0KKwkJaWYgKGRvaXQpIHsKKwkJICAgIGlmIChkaXJjID09ICcgJykgeworCQkJcHJpbnRmICgiICU4bGQgICAlcyVjXG4iLAorCQkJCShsb25nKSBGQVQyQ1BVMzIgKGRlbnRwdHItPnNpemUpLCBzX25hbWUsCisJCQkJZGlyYyk7CisJCSAgICB9IGVsc2UgeworCQkJcHJpbnRmICgiICAgICAgICAgICAgJXMlY1xuIiwgc19uYW1lLCBkaXJjKTsKKwkJICAgIH0KKwkJfQorCQlkZW50cHRyKys7CisJCWNvbnRpbnVlOworCSAgICB9CisJICAgIGlmIChzdHJjbXAgKGZpbGVuYW1lLCBzX25hbWUpICYmIHN0cmNtcCAoZmlsZW5hbWUsIGxfbmFtZSkpIHsKKwkJRkFUX0RQUklOVCAoIk1pc21hdGNoOiB8JXN8JXN8XG4iLCBzX25hbWUsIGxfbmFtZSk7CisJCWRlbnRwdHIrKzsKKwkJY29udGludWU7CisJICAgIH0KKwkgICAgbWVtY3B5IChyZXRkZW50LCBkZW50cHRyLCBzaXplb2YgKGRpcl9lbnRyeSkpOworCisJICAgIEZBVF9EUFJJTlQgKCJEZW50TmFtZTogJXMiLCBzX25hbWUpOworCSAgICBGQVRfRFBSSU5UICgiLCBzdGFydDogMHgleCIsIFNUQVJUIChkZW50cHRyKSk7CisJICAgIEZBVF9EUFJJTlQgKCIsIHNpemU6ICAweCV4ICVzXG4iLAorCQkJRkFUMkNQVTMyIChkZW50cHRyLT5zaXplKSwKKwkJCShkZW50cHRyLT5hdHRyICY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